package com.spark.gaea.data.utils;

import com.google.common.base.Preconditions;
import com.google.common.collect.Maps;

import java.util.Map;

public class Param {
	private Map<String, Object> pms;

	public Param() {
		this.pms = Maps.newHashMap();
	}

	public static Param get() {
		return new Param();
	}

	public Param put(final String key, final Object value) {
		if (value == null) {
			return this;
		}
		this.pms.put((String) Preconditions.checkNotNull((Object) key), value);
		return this;
	}

	public Param putLikeLR(final String key, final String value) {
		if (value == null) {
			return this;
		}
		this.pms.put((String) Preconditions.checkNotNull((Object) key), "%" + value + "%");
		return this;
	}

	public Param putLikeL(final String key, final String value) {
		return getParam(key, value, "%", value);
	}

	private Param getParam(Object key, String value, String s, String value2) {
		if (value == null) {
			return this;
		}
		this.pms.put((String) Preconditions.checkNotNull(key), s + value2);
		return this;
	}

	public Param putLikeR(final String key, final String value) {
		return getParam(key, value, value, "%");
	}

	public Map<String, Object> build() {
		return this.pms;
	}
}
